﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for NewITSelfCalculator
/// </summary>
public class ITSelfCalculator2012
{
    public ITSelfCalculator2012()
    {
    }

    public static double CalculateTax(double totalAnnualIncome)
    {
        if (totalAnnualIncome <= 400000)
            return Slab1Tax(totalAnnualIncome);
        else if (totalAnnualIncome <= 750000)
            return Slab2Tax(totalAnnualIncome);
        else if (totalAnnualIncome <= 1500000)
            return Slab3Tax(totalAnnualIncome);
        else if (totalAnnualIncome <= 2500000)
            return Slab4Tax(totalAnnualIncome);
        else
            return Slab5Tax(totalAnnualIncome); ;
    }

    // Income <= 400,000
    private static double Slab1Tax(double income)
    {
        return 0;
    }

    // 400,000 < Income <= 750,000
    private static double Slab2Tax(double income)
    {
        const int baseValue = 400000;
        const int fixedTax = 0;
        return fixedTax + Percentage(income - baseValue, 10);
    }

    // 750,000 < Income <= 1,500,000
    private static double Slab3Tax(double income)
    {
        const int baseValue = 750000;
        const int fixedTax = 35000;
        return fixedTax + Percentage(income - baseValue, 15);
    }

    // 1,500,000 < Income <= 2,500,000
    private static double Slab4Tax(double income)
    {
        const int baseValue = 1500000;
        const int fixedTax = 147500;
        return fixedTax + Percentage(income - baseValue, 20);
    }

    // 2,500,000 < Income
    private static double Slab5Tax(double income)
    {
        const int baseValue = 2500000;
        const int fixedTax = 347500;
        return fixedTax + Percentage(income - baseValue, 25);
    }

    private static double Percentage(double amount, int percent)
    {
        return (amount * percent) / 100;
    }
}
